//
//  PSViewController.m
//  Pingguo
//
//  Created by dgw on 15/8/14.
//  Copyright (c) 2015年 mohekeji. All rights reserved.
//

#import "PSViewController.h"
#import "GUOTableViewCell.h"
#import "SJViewController.h"
#define Height 59
@interface PSViewController ()
<UIAlertViewDelegate>
@end

@implementation PSViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [[NSUserDefaults standardUserDefaults]setValue:@"dg" forKey:@"name"];
    [[NSUserDefaults standardUserDefaults]removeObjectForKey:@"name"];
    NSString*rrr;
    int a=2;
    int s=4;
    rrr=a>s?@"大于":@"小于";
    _dataArr = @[
                   @{
                       @"headerTitle": @"宝骏560即将耀目登场1",
                       @"headerConetent": @"我是content",
                       @"footTitle": @"宝骏560即将耀目登场2",
                       @"footContent": @"我是footcontent",
                       @"list": @[
                               @{
                                   @"title": @"宝骏560即将耀目登场",
                                   @"content": @"宝骏560即将耀目登场",
                                   },
                               @{
                                   @"title": @"宝骏560即将耀目登场",
                                   @"content": @"宝骏560即将耀目登场",
                                   }
                               ]
                       },
                   @{
                       @"headerTitle": @"宝骏560即将耀目登场2",
                       @"footContent": @"我是footcontent",
                       @"headerConetent": @"我是content",
                       @"footTitle": @"宝骏560即将耀目登场2",
                       @"list": @[
                               @{
                                   @"title": @"宝骏560即将耀目登场",
                                   @"content": @"宝骏560即将耀目登场",
                                   
                                   },
                               @{
                                   @"title": @"宝骏560即将耀目登场",
                                   @"content": @"宝骏560即将耀目登场",
                                   
                                   }
                               ]
                       },
                   @{
                       @"headerTitle": @"宝骏560即将耀目登场3",
                       @"headerConetent": @"我是content",
                       @"footTitle": @"宝骏560即将耀目登场2",
                       @"footContent": @"我是footcontent",
                    
                       @"list": @[
                               @{
                                   @"title": @"宝骏560即将耀目登场",
                                   @"content": @"宝骏560即将耀目登场",
                                   },
                               @{
                                   @"title": @"宝骏560即将耀目登场",
                                   @"content": @"宝骏560即将耀目登场",
                                   }
                               ]                       },
                   @{
                       @"headerTitle": @"宝骏560即将耀目登场4",
                       @"headerConetent": @"我是content",
                       @"footTitle": @"宝骏560即将耀目登场2",
                       @"footContent": @"我是footcontent",
                       @"list": @[
                               @{
                                   @"title": @"宝骏560即将耀目登场",
                                   @"content": @"宝骏560即将耀目登场",
                                   },
                               @{
                                   @"title": @"宝骏560即将耀目登场",
                                   @"content": @"宝骏560即将耀目登场",
                                   }
                               ]
                       },
                   @{
                       @"headerTitle": @"宝骏560即将耀目登场1",
                       @"headerConetent": @"我是content",
                       @"footTitle": @"宝骏560即将耀目登场2",
                       @"footContent": @"我是footcontent",
                       @"list": @[
                               @{
                                   @"title": @"宝骏560即将耀目登场",
                                   @"content": @"宝骏560即将耀目登场",
                                   },
                               @{
                                   @"title": @"宝骏560即将耀目登场",
                                   @"content": @"宝骏560即将耀目登场",
                                   }
                               ]
                       }
                   ];
    // Do any additional setup after loading the view from its nib.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    NSDictionary *dic = [_dataArr objectAtIndex:section];
    
    NSArray *arr = [dic objectForKey:@"list"];
    return arr.count;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    UIView *headerView = [[UIView alloc] init];
    headerView.frame = CGRectMake(0, 0, 320, 59);
    headerView.backgroundColor = [UIColor grayColor];
    // add label
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 200, 21)];
    NSDictionary *dic = [_dataArr objectAtIndex:section];
    label.text = dic[@"headerTitle"];
    
    
    // add label
    UILabel *labelContet = [[UILabel alloc] initWithFrame:CGRectMake(10, 35, 200, 21)];
    
    labelContet.text = dic[@"headerConetent"];
    
    [headerView addSubview:label];
    return headerView;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return _dataArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
   GUOTableViewCell*cell=[[[NSBundle mainBundle]loadNibNamed:@"GUOTableViewCell" owner:self options:nil]lastObject];
    NSDictionary*dicOne=[_dataArr objectAtIndex:indexPath.section];
    NSArray*arr=dicOne[@"list"];
    NSDictionary*dicTwo=[arr objectAtIndex:indexPath.row];
    cell.gg.text=dicTwo[@"title"];
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    
    
    return Height;
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
   SJViewController *vc = [[SJViewController alloc] init];
   [self.navigationController pushViewController:vc animated:YES];
    UIAlertView*EEE=[[UIAlertView alloc]initWithTitle:@"提示" message:@"确定退出？" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
    [EEE show];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{if (buttonIndex==0) {NSLog(@"崩溃");}
    else  {NSLog(@"确认取消吗");}}
@end
